package com.zcx.qshop.conn;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

@HttpInlet(Conn.INLET_JSON_COLLECT)
public class JsonCollectAsyGet extends QSAsyGet<JsonCollectAsyGet.Info> {
	
	public String uid; 

	public JsonCollectAsyGet(String uid, AsyCallBack asyCallBack) {

		super(asyCallBack);
		
		this.uid = uid;
		
 	}
	
	@Override
	public Info parser(JSONObject object) { 
		
		if(object.optString("message").equals("1")){
			
			Info info = new Info();
			
			JSONArray array = object.optJSONArray("collectlist");
			
			for (int i = 0; i < array.length(); i++) {

				Info.Collect collect = new Info.Collect();
				
				JSONObject o = array.optJSONObject(i);

				collect.gid = o.optString("gid");

				collect.cid = o.optString("cid");

				collect.title = o.optString("title");

				collect.picurl = Conn.SERVICE + o.optString("picurl");

				collect.info = o.optString("info");

				collect.price = o.optString("price");
				
				info.collects.add(collect);
				
			} 
			
			return info;
			
		}
		
		return null;
		
	}

	public static class Info{
		
		public List<Collect> collects = new ArrayList<Collect>();

		public static class Collect{

			public String gid, cid, title, picurl, info, price;

		}
		
	}
	
}
